package com.ds.dalgen;

import java.util.List;
import java.util.Map;

import com.ds.dalgen.context.Context;
import com.ds.dalgen.db.domain.TableCol;
import com.ds.dalgen.db.domain.TableInfo;
import com.ds.dalgen.generator.Generator;
import com.ds.dalgen.generator.SqlMapGenerator;
import com.ds.dalgen.generator.VoGenerator;
import com.ds.dalgen.generator.domain.GeneratorInfo;
import com.ds.dalgen.generator.domain.Operation;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Context context = new Context();

		Map<String, TableInfo> tableInfos = context.getTableInfos();
		for (String key : tableInfos.keySet()) {
			TableInfo tableInfo = tableInfos.get(key);
			p("TableName: " + tableInfo.getTableName());
			p("pk: " + tableInfo.getPrimaryKey());

			Map<String, TableCol> tableCols = tableInfo.getTableCols();
			for (String colkey : tableCols.keySet()) {
				TableCol tableCol = tableCols.get(colkey);
				p("colName: " + tableCol.getName());
			}
		}

		List<GeneratorInfo> generatorInfos = context.getGeneratorInfos();
		for (GeneratorInfo generatorInfo : generatorInfos) {
			p(generatorInfo.getTableAlias());
			List<Operation> operations = generatorInfo.getOperations();
			for (Operation operation : operations) {
				p(operation.getType());
			}
		}

		Generator generator = new VoGenerator();
		generator.generator(context);

		generator = new SqlMapGenerator();
		generator.generator(context);

	}

	public static void p(String s) {
		System.out.println(s);
	}

}
